import { request, requestBaijiahao } from '../utils/request'
import { storage } from '../utils/storage'

// 获取文章列表
export const userSiteArticleList = (params:any) => {
  return request({
    url: '/userSiteArticle/list',
    method: 'GET',
    params,
  })
}

// 文章详情
export const userSiteArticleDetails = (params:any) => {
    return request({
      url: '/userSiteArticle/details',
      method: 'GET',
      params,
    })
}

// 获取文章图片的压缩文件
export const userSiteArticleZipImage = (params:any) => {
    return request({
      url: '/userSiteArticle/zipImage',
      method: 'GET',
      params,
    })
}

// 设置文章已发布
export const userSiteArticleSetRelease = (data:any) => {
    return request({
      url: '/userSiteArticle/setRelease',
      method: 'POST',
      data,
    })
}

// 编辑站点名称
export const user_site_edit = (data:any) => {
  return request({
    url: '/user_site/edit',
    method: 'POST',
    data,
  })
}
// 判断是否可以发布
export const user_editPrev = (data:any) => {
  return request({
    url: '/user_site/editPrev',
    method: 'POST',
    data,
  })
}
// 百家号从返回的header中解析出token
export const getuserinfo = (cookie:any) => {
  return requestBaijiahao({
    url: '/activity/markactivity/getuserinfo?pop_type=homepage',
    method: 'GET',
    headers: {
      'Cookie': cookie,
    }
  })
}

// 上传图片
export const pictureUploadproxy = (formData:any) => {
  return requestBaijiahao({
    url: '/pcui/picture/uploadproxy',
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
      // 'Host':'baijiahao.baidu.com',
      // 'Origin': 'https://baijiahao.baidu.com',
      // 'Referer': 'https://baijiahao.baidu.com/builder/rc/edit?type=news',
      'Token': storage.get('baijiahao-Token'),
    }
  })
}

// 发布百家号草稿箱
export const articleSave = (data:any) => {
  const formData:any = new FormData()
  formData.append('type','news')
  // formData.append('content','3242344444444444444444444')
  // const params = new URLSearchParams(formData)
  var urlencoded = new URLSearchParams();
  urlencoded.append("type", "news");
  return requestBaijiahao({
    url: '/pcui/article/save',
    method: 'POST',
    // params: {
    //   callback: 'bjhdraft'
    // },
    // qs.stringify
    data:  data,
    headers: {
      'Accept': 'application/json, text/plain, */*',
      'Content-Type': 'application/x-www-form-urlencoded',
      'Host': 'baijiahao.baidu.com',
      'Origin': 'https://baijiahao.baidu.com',
      'Referer': 'https://baijiahao.baidu.com/builder/rc/edit?type=events',
      'Token': storage.get('baijiahao-Token'),
      // "Cookie": 'BIDUPSID=9783AE509A6A036AAC8B53CCEB41763C; PSTM=1705024699; MAWEBCUID=web_cZszphDSxGIzOqcQhAhfKyaToGOCRAUixLRqECRcQSKibcurXH; BAIDUID=8A2C4E89670246269AB9ACB328B14E8C:FG=1; theme=bjh; H_WISE_SIDS_BFESS=60278_61027_61737_61780_61890_61986; BDUSS_BFESS=V2fmhSVk55ZkNYNWcyOVQyckQtRVVkTmNscHJ4dmwzZWljbG1rVDlUby1OYjFuSUFBQUFBJCQAAAAAAAAAAAEAAAD33pBVTGVlenlvdW5nNjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD6olWc-qJVnMF; BAIDUID_BFESS=8A2C4E89670246269AB9ACB328B14E8C:FG=1; ZFY=8Gv6l0Tb8uNNDUaodn6twUnuTaSIuPdlhpPAJke0BQk:C; Hm_lvt_f2ee7f5c2284ca4c112e62165bc44c75=1737863134; devStoken=4ca78e763eea87fc365ba6d754f582a9a25b10f89abb03aefe0121fcb1d5b8f9; bjhStoken=0a11458787e6b087d1422798a4f067c3a25b10f89abb03aefe0121fcb1d5b8f9; BAIDU_WISE_UID=wapp_1737863408693_6; H_PS_PSSID=60278_61027_61986; BA_HECTOR=252gal200l0g8h81202g218kbjfmvi1jq8sdg1u; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0; PSINO=2; delPer=0; H_WISE_SIDS=60278_61027_61986; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; Hm_lvt_f7b8c775c6c8b6a716a75df506fb72df=1737705805,1737800254,1737861184,1738898174; HMACCOUNT=D50073EF615640A1; PHPSESSID=ku2rimn89gqvarg6672djmvoh4; __bid_n=194de68744998883db3d9f; XFI=e3dd3db0-e501-11ef-9344-03e1f5215762; XFCS=0679D43874BF8828D770AC56AD93AE7AF45E8647CAE0745C32EEFC91FE65B3F3; XFT=xUkL/VcJ0W6Mqnl7sn3PR46Mhw8ufiJ0OFYK6+MGMfU=; Hm_lpvt_f7b8c775c6c8b6a716a75df506fb72df=1738898210; ab_sr=1.0.1_YTk2NGU1ZDA5YmI4MmJhZjc4YmY2ZjI4MjIyNTZhNDAxYmUxNmEyOWI2YjFlZDFhN2JlYzAyZTk5MzBlZDYzOTZhZmFkODA1OGZmZmJkMDcxNGJkOTIzOTg1ZmVhZmNlOWYxZGIzY2U2NjI5NjljZDI2YWJiMDRkOTEzYmZlNzdjMjRmZjZjYmRhYzM1NTI5ZDFjY2Y2MWNkNTQwMmVjNDI0N2Y2MDQyYmJhZDUyMTliNTljZjQ0MjI2ZGYwYTgxYjkxOTQ2NjBjNmNiN2UxMjNjMGIwYjAyN2I0ZDM4ZGMzN2Y4Y2RjMmE0NWM5OTBjMzI2MmYzZDEzMjZlNWFmMg==; RT="z=1&dm=baidu.com&si=287182a9-3581-4747-9dea-8cb2c0394c1d&ss=m6u72pr2&sl=a&tt=dya&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&ld=108w"',
      'Accept-Language': 'zh-CN,zh;q=0.9'
    }
  })
}

// 发布百家号正式
export const articlePublish = (data:any) => {
  const formData:any = new FormData()
  formData.append('type','news')
  // formData.append('content','3242344444444444444444444')
  // const params = new URLSearchParams(formData)
  var urlencoded = new URLSearchParams();
  urlencoded.append("type", "news");
  return requestBaijiahao({
    url: '/pcui/article/publish?callback=bjhpublish',
    method: 'POST',
    data:  data,
    headers: {
      'Accept': 'application/json, text/plain, */*',
      'Content-Type': 'application/x-www-form-urlencoded',
      'Host': 'baijiahao.baidu.com',
      'Origin': 'https://baijiahao.baidu.com',
      'Referer': 'https://baijiahao.baidu.com/builder/rc/edit?type=events',
      'Token': storage.get('baijiahao-Token'),
      'Accept-Language': 'zh-CN,zh;q=0.9'
    }
  })
}

// 百家号发布列表
export const articleLists = (data:any) => {
  return requestBaijiahao({
    url: '/pcui/article/lists',
    method: 'GET',
    params: data,
    headers: {
      'Token': storage.get('baijiahao-Token'),
    }
  })
}

// 删除
export const articleRemove = (data:any) => {
  return requestBaijiahao({
    url: '/pcui/article/remove',
    method: 'POST',
    data: data,
    headers: {
      'Accept': 'application/json, text/plain, */*',
      'Content-Type': 'application/x-www-form-urlencoded',
      'Host':'baijiahao.baidu.com',
      'Origin': 'https://baijiahao.baidu.com',
      'Token': storage.get('baijiahao-Token'),
    }
  })
}

// 撤回
export const articleWithdraw = (data:any) => {
  return requestBaijiahao({
    url: '/pcui/article/withdraw',
    method: 'POST',
    data: data,
    headers: {
      'Accept': 'application/json, text/plain, */*',
      'Content-Type': 'application/x-www-form-urlencoded',
      'Host':'baijiahao.baidu.com',
      'Origin': 'https://baijiahao.baidu.com',
      'Token': storage.get('baijiahao-Token'),
    }
  })
}

// 百家号获取阅读量
export const adnewspvtrend = (data:any) => {
  return requestBaijiahao({
    url: '/author/eco/income2/adnewspvtrend',// /author/eco/income2/advideopvtrend
    method: 'GET',
    params: data,
    headers: {
      'Token': storage.get('baijiahao-Token'),
    }
  })
}
// 百家号获取昨日阅读数
export const getAppStatistic = (data:any) => {
  return requestBaijiahao({
    url: '/author/eco/statistics/appStatistic',
    method: 'GET',
    params: data,
    headers: {
      'Cache-Control': 'no-cache', // 根据需要设置 Cache-Control 值
      'Token': storage.get('baijiahao-Token')
    }
  })
}
// 百家号获取总阅读数
export const getauthorhistory = () => {
  return requestBaijiahao({
    url: '/author/eco/statistic/getauthorhistory',
    method: 'GET',
    headers: {
      'Token': storage.get('baijiahao-Token')
    }
  })
}

// 百家号获取收益
export const adnewsincometrend = (data:any) => {
  return requestBaijiahao({
    url: '/author/eco/income2/adnewsincometrend',
    method: 'GET',
    params: data,
    headers: {
      'Token': storage.get('baijiahao-Token'),
    }
  })
}
// 百家号获取本月收益、本周收益
export const adnewsincomeoverview = (data:any) => {
  return requestBaijiahao({
    url: '/author/eco/income2/adnewsincomeoverview',
    method: 'GET',
    params: data,
    headers: {
      'Token': storage.get('baijiahao-Token'),
    }
  })
}

// 百家号获取总收益
export const getNewtotalincome = () => {
  return requestBaijiahao({
    url: '/author/eco/income2/newtotalincome',
    method: 'GET',
    headers: {
      'Token': storage.get('baijiahao-Token'),
    }
  })
}
// 百家号获取剩余发布数
export const articlePublishNum = (data:any) => {
  return requestBaijiahao({
    url: '/pcui/article/edit',
    method: 'GET',
    params: data,
    headers: {
      'Token': storage.get('baijiahao-Token'),
    }
  })
}

// 活动投稿
export const getSquareMissionList = (params:any) => {
  return requestBaijiahao({
    url: '/author/eco/tasksystem/getSquareMissionList',
    method: 'GET',
    params: params,
    headers: {
      'Token': storage.get('baijiahao-Token'),
    }
  })
}
